import configparser
import os

root_path = os.path.dirname(__file__)
config = configparser.ConfigParser()
config.read(os.path.join(root_path, 'config.ini'))
# Create dummy secrey key so we can use sessions

SECRET_KEY = config.get('website', 'SECRET_KEY')

# Create in-memory database
SQLALCHEMY_DATABASE_URI = config.get('db', 'SQLALCHEMY_DATABASE_URI')
SQLALCHEMY_TRACK_MODIFICATIONS = config.getboolean('db', 'SQLALCHEMY_TRACK_MODIFICATIONS')
SQLALCHEMY_ECHO = config.getboolean('db', 'SQLALCHEMY_ECHO')
DEBUG = config.getboolean('db', 'DEBUG')

# Flask-Security config
SECURITY_URL_PREFIX = config.get('FlaskSecurity', 'SECURITY_URL_PREFIX')
SECURITY_PASSWORD_HASH = config.get('FlaskSecurity', 'SECURITY_PASSWORD_HASH')
SECURITY_PASSWORD_SALT = config.get('FlaskSecurity', 'SECURITY_PASSWORD_SALT')

# Flask-Security URLs, overridden because they don't put a / at the end
SECURITY_LOGIN_URL = config.get('FlaskSecurity', 'SECURITY_LOGIN_URL')
SECURITY_LOGOUT_URL = config.get('FlaskSecurity', 'SECURITY_LOGOUT_URL')
SECURITY_REGISTER_URL = config.get('FlaskSecurity', 'SECURITY_REGISTER_URL')

SECURITY_POST_LOGIN_VIEW = config.get('FlaskSecurity', 'SECURITY_POST_LOGIN_VIEW')
SECURITY_POST_LOGOUT_VIEW = config.get('FlaskSecurity', 'SECURITY_POST_LOGOUT_VIEW')
SECURITY_POST_REGISTER_VIEW = config.get('FlaskSecurity', 'SECURITY_POST_REGISTER_VIEW')

# Flask-Security features
SECURITY_REGISTERABLE = config.getboolean('FlaskSecurity', 'SECURITY_REGISTERABLE')
SECURITY_SEND_REGISTER_EMAIL = config.getboolean('FlaskSecurity', 'SECURITY_SEND_REGISTER_EMAIL')

HOST = '0.0.0.0'
PORT = '5000'